/*
 * Seat.fx
 *
 * Created on Apr 27, 2009, 3:28:27 PM
 */

package com.dg.gaming.client.fx.gui;

import javafx.scene.Cursor;
import javafx.scene.CustomNode;
import javafx.scene.Group;
import javafx.scene.Node;
import javafx.scene.paint.Color;
import javafx.scene.shape.LineTo;
import javafx.scene.shape.MoveTo;
import javafx.scene.shape.Path;
import javafx.scene.shape.Rectangle;

public class Seat extends CustomNode{

     def DEF=5;
     public var index:Integer;
     public var size:Integer;
     public var color:Color;
     public var selected=false;


     public var select:function(index:Integer);


     public override  function create():Node {
         return Group{

             content:[
             Rectangle{
                     x:0
                     y:0
                     width:size
                     height:size
                     stroke:Color.BLACK;
                     fill: bind color
                     cursor:Cursor.HAND;
                     onMousePressed:function(event){
                            select(index);
                     }

                 },
             Path{
                 fill: bind color
                 stroke:Color.BLACK
                 visible:bind selected
                 elements: [
                    MoveTo{x:DEF,y:DEF},
                    LineTo{x:size-DEF,y:DEF},
                    LineTo{x:size-DEF,y:size-DEF},
                    LineTo{x:DEF,y:size-DEF},
                    LineTo{x:DEF,y:DEF}

                 ]
             }

             ]

         }

         ;
     }
}
